<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = [{
            id: 3,
            name: "test2"
        }, {}, {
            ia: "4",
            name: "test1"
        }, {
            id: 6,
            name: "test3"
        }, {
            id: () => { },
            name: "test7"
        }, {
            id: 2,
            name: "test5"
        }]

        function newarr(arr){
            let arr1=arr.filter(item=>{
                return typeof item.id === "number"
            })

            let arr2=arr1.sort((a,b)=>{
                return a.id - b.id;
            })
            // console.log(arr2);
            arr2.forEach(item=>{
                console.log(item.name);
            })
        }
        newarr(arr)

    </script>
</body>

</html>